import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ObjCreate } from "../common/ObjCreate";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { WuXingSkillChangePanel } from "./WuXingSkillChangePanel";
import { GameController } from "../../mvc/GameController";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { WuXingPlayerInfo } from "../../model/wuxing/WuXingPlayerInfo";
import { WuXingRule } from "../../rules/WuXingRule";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
type int = number;
//class WuXingRefreshAttrPanel
    
    export  class WuXingRefreshAttrPanel /* flash.display.Sprite */
    {
        constructor(arg1: int, arg2: int)
        {
            
            this._width = arg1;
            this._height = arg2;
            this.initUI();
            return;
        }

        protected onWuXingBgLoadedHandler(): void
        {
            this._refreshFontBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.wxRefreshFont);
            this._skillFontBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.wxSkillFont);
            return;
        }

        protected initUI(): void
        {
            this._refreshFontBmp = new Object /* flash.display.Bitmap */();
            this._refreshFontBmp.x = 10;
            this._refreshFontBmp.y = 10;
            addChild(this._refreshFontBmp);
            var loc1=new GTextFormat("", 12, GlobalStyle.color1Uint);
            loc1.leading = 4;
            this._refreshFontTxt = ObjCreate.createTextField("", this._refreshFontBmp.x, this._refreshFontBmp.y + 30, this.width, 40, this, loc1);
            this._refreshFontTxt.textColor = 65280;
            this._refreshFontTxt.multiline = true;
            this._refreshFontTxt.wordWrap = true;
            this._line = ResouceConst.getScaleBitmap(ImagesConst.SplitLine);
            this._line.width = 260;
            this._line.y = 97;
            this._line.x = 10;
            addChild(this._line);
            this._skillFontBmp = new Object /* flash.display.Bitmap */();
            this._skillFontBmp.x = this._refreshFontBmp.x;
            this._skillFontBmp.y = this._line.y + 15;
            addChild(this._skillFontBmp);
            this._skillFontTxt = ObjCreate.createTextField("", this._skillFontBmp.x + 92, this._skillFontBmp.y + 2, 200, 20, this);
            this._skillChangeTxt = ObjCreate.createTextField("", this._skillFontTxt.x + 95, this._skillFontTxt.y, 200, 20, this);
            this._skillChangeTxt.htmlText = HTMLUtil.addColor("<u><a href=\'event: 0\'>" + Language.getString(26395) + "</a></u>", "#00ff00");
            this._skillChangeTxt.addEventListener(flash.events.TextEvent.LINK, this.onSkillChangeClickHandler);
            LoaderHelp.addResCallBack(ResFileConst.wuxing, this.onWuXingBgLoadedHandler);
            return;
        }

        /* internal  */onSkillChangeClickHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            if (!this._skillChangePanel) 
            {
                this._skillChangePanel = new WuXingSkillChangePanel(GameController.wuxing.view as ILayer);
            }
            if (this._skillChangePanel.isHide) 
            {
                this._skillChangePanel.updateData(this._info);
                this._skillChangePanel.show();
            }
            return;
        }

        public updateData(arg1: WuXingPlayerInfo): void
        {
            this._info = arg1;
            if (!this._info) 
            {
                return;
            }
            this._skillFontTxt.htmlText = HTMLUtil.addColor("（" + Language.getString(26386) + "：" + this._info.getMainAttrHtmlName() + "）", "#ffff00");
            this._refreshFontTxt.htmlText = HTMLUtil.addColor(Language.getStringByParam(26385, this._info.getMainAttrHtmlName(), WuXingRule.getRelationName(this._info.mainAttribute, WuXingRule.Relation_AddFrom, true), WuXingRule.getRelationName(this._info.mainAttribute, WuXingRule.Relation_DelFrom, true)), GlobalStyle.color1);
            if (this._skillChangePanel && !this._skillChangePanel.isHide) 
            {
                this._skillChangePanel.updateData(this._info);
            }
            if (this._info.skillAble) 
            {
                if (!this._skillChangeTxt.parent) 
                {
                    addChild(this._skillChangeTxt);
                }
            }
            else if (this._skillChangeTxt.parent) 
            {
                removeChild(this._skillChangeTxt);
            }
            return;
        }

        public dispose(): void
        {
            return;
        }

        public /* override */ get width(): number
        {
            return this._width;
        }

        public /* override */ get height(): number
        {
            return this._height;
        }

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_height: int;

        /* internal */ /* var */_info: WuXingPlayerInfo;

        /* internal */ /* var */_refreshFontBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_refreshFontTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_line: ScaleBitmap;

        /* internal */ /* var */_skillFontBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_skillFontTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_skillChangeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_skillChangePanel: WuXingSkillChangePanel;
    }
